Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wildcards in database name #1666

Merged
merged 8 commits into from
Mar 28, 2023
Merged

fix: wildcards in database name #1666

merged 8 commits into from
Mar 28, 2023

Conversation

sfc-gh-swinkler
Copy link
Collaborator

Describe the bug

Issue with two databases due to their names since the query used by Terraform (SHOW DATABASES LIKE '') returns more than one value generating a Terraform plan with unexpected replacements (image attached)

Expected behavior

It should be presenting 1 result instead of 2 .

Code samples and commands

SHOW DATABASES LIKE ''; --return 2 rows

Additional context

Customer wants Snowflake to enhance the terraform script.
The underscore wild card is SQL standard, and works in oracle, mysql, sql server and postegresql .They are not willing to change the database name but rather wants us to make the Terraform script changes.They want to make Terraform provider for Snowflake, wildcard proof.
SQL wildcards are supported in pattern:
An underscore (_) matches any single character.
A percent sign (%) matches any sequence of zero or more characters.
Wildcards in pattern include newline characters (\n) in subject as matches.
LIKE pattern matching covers the entire string. To match a sequence anywhere within a string, start and end the pattern with %.
We asked customer to use account_usage.databases view or information_schema.databases view, and filter by the DATABASE_NAME='dbname'.
SHOW DATABASE is doing "LIKE" condition and querying the account_usage.databases view where DATABASE_NAME='dbname' will provide the exact match.
The above suggestion was rejected since the same query cannot be injected into Terraform’s source cod

@github-actions
Copy link

Integration tests failure for 1c5a7735bf8d0aa016bce0f8eaa3c5cd0e06f323

@github-actions
Copy link

Integration tests failure for 67a12b36069653b9acedf65c0ce5d8a0a81fa9f8

@github-actions
Copy link

Integration tests failure for db18992b3c1aa773f583b09d5ee8a27e9b782333

@github-actions
Copy link

Integration tests failure for 1d1edd18dfb6911ad3ff3f60e83623a9b0b6b2ef

@github-actions
Copy link

Integration tests success for f0f265e4153dff6a593240d90fdd56a15fff4596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant